﻿using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WPFStudy.ViewModel
{
    public class MvvmLightWindowVM:ViewModelBase
    {
        int _count = 0;
        #region 名称
        /// <summary>
        /// 名称
        /// </summary>
        private string? _name;

        /// <summary>
        /// 名称
        /// </summary>
        public string? Name
        {
            get => _name;
            set => Set(ref _name, value);
        }
        #endregion 名称

        #region 按钮点击命令

        /// <summary>
        /// 按钮点击命令
        /// </summary>
        private RelayCommand? _buttonClickCmd;

        /// <summary>
        /// 按钮点击命令
        /// </summary>
        public RelayCommand? ButtonClickCmd
        {
            get
            {
                if (_buttonClickCmd == null)
                {
                    _buttonClickCmd = new RelayCommand(ButtonClick);
                }

                return _buttonClickCmd;
            }
            set { _buttonClickCmd = value; }

        }

        /// <summary>
        /// 按钮点击命令
        /// </summary>
        private void ButtonClick()
        {
            _count++;
            Name = $"Button Click - {_count}";
        }

        #endregion 按钮点击命令
    }
}
